package top.jianx.music.provider.netease;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import top.jianx.music.enums.MusicProvider;
import top.jianx.music.model.BaseBean;
import top.jianx.music.model.MusicLink;
import top.jianx.music.model.Song;
import top.jianx.music.util.SongUtils;

import java.util.ArrayList;

@Data
public class NeteaseSong extends BaseBean implements Song {

    @JSONField(name = "name")
    public String name;

    @JSONField(name = "id")
    public long songId;

    @JSONField(name = "ar", alternateNames = {"artists",})
    public ArrayList<NeteaseArtist> artists;

    @JSONField(name = "al", alternateNames = {"album",})
    public NeteaseAlbum album;

    private MusicLink musicLink;

    private NeteaseLyric lyric;

    @Override
    public String getSongId() {
        return String.valueOf(songId);
    }

    @Override
    public String getFormattedArtistsString() {
        return SongUtils.getArtistsString(this);
    }

    @Override
    public MusicProvider getMusicProvider() {
        return MusicProvider.Netease;
    }

    @Override
    public String getPicUrl() {
        if (album != null) {
            return album.picUrl;
        }
        return null;
    }
}
